<?php
	####################################################
	# library import and object instance.              #
	####################################################
	include_once('./common.php');
	include_once('./ncrud_common.php');


	####################################################
	# request data($_POST AND $_GET FROM $_REQUEST)    #
	####################################################
	# REQUEST(get and post variables)
	$req = Request::clean_request($_REQUEST, FALSE);

	# GET(url variables)

	# POST(form variables)

	# Validation(special case validate)

	####################################################
	# implementation                                   #
	####################################################
	//*/
	$pagenation_cfg = array(
		'uri'				=> "ncrud_list.php",
		'articles_count'	=> 20,
		'req_page'			=> $req['pagenation'],
		'page_size'			=> 6,
		'articles_cnt'		=> $db->getcnts($ncrud['table_name']),
		'style'				=> Pagenation::$style_default
	);
	$article = $db->gets(
		sprintf("SELECT * FROM `%s` ORDER BY buid DESC LIMIT %s, %s ",
			$ncrud['table_name'],
			$pagenation_cfg['req_page'] * $pagenation_cfg['articles_count'],
			$pagenation_cfg['articles_count']
		)
	);
	$pagenation = Pagenation::out($pagenation_cfg);
	//*/
?>
<?php
	$html->custom_header(TITLE);
	$html->custom_js("{$JS}jquery.1.7.1.min.js");
	$html->custom_js("{$JS}lib.control.js");
	$html->custom_css("{$CSS}basic.css");
?>
<?$html->custom_body();?>
<?=$tmp->tiles_header()?>
	<h1>ncrud - list</h1>
		<table width="100%" border="1" cellspacing="3" cellpadding="0">
			<tr>
				<th>
					유니크 아이디(buid)
				</th>
				<th>
					이름(bname)
				</th>
				<th>
					이름-영문(bname_eng)
				</th>
				<th>
					활성(benable)
				</th>
			</tr>
			<?php foreach($article['res'] as $key=>$val):?>
				<tr>
					<td>
						<?=$val['buid']?>
					</td>
					<td>
						<a href="./ncrud_retrieve.php?buid=<?=$val['buid']?>">
							<?=$val['bname']?>
						</a>
					</td>
					<td>
						<?=$val['bname_eng']?>
					</td>
					<td>
						<?=$val['benable']?>
					</td>
				</tr>
			<?php endforeach;?>
		</table>
		<?=$pagenation?>
	<?=NTool::btn("생성", "Mover.href('./ncrud_create.php');");?>
	<span> | </span>
	<?=NTool::btn("뒤로", "Mover.back();");?>
	<?=NTool::btn("인덱스", "Mover.home();");?>
<?=$tmp->tiles_footer()?>
<?php $html->html_footer(); ?>